@extends('common.admin_common')
@section('content')
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="#">首页</a> &raquo; <a href="#">文章管理</a> &raquo; 添加文章
    </div>
    <!--面包屑导航 结束-->

	<!--结果集标题与导航组件 开始-->
    @if(count($errors)>0)
        <div class="result_wrap">
            <div class="result_title">
                <div class="mark">
                    @if(is_object($errors))
                        @foreach($errors->all() as $error)
                            <p>{{$error}}</p>
                        @endforeach
                    @else
                        <p>{{$errors}}</p>
                    @endif
                </div>
            </div>
        </div>
        @endif
    <!--结果集标题与导航组件 结束-->
    
    <div class="result_wrap">
        <form action="{{url('admin/article')}}" method="post">
            {!!csrf_field()!!}
            <table class="add_tab">
                <tbody>
                <tr>
                    <th width="120">分类：</th>
                    <td>
                        <select name="cate_id">
                            @foreach($data as $v)
                                <option value="{{$v->cate_id}}">{{$v->html}}{{$v->cate_name}}</option>
                            @endforeach
                        </select>
                    </td>
                </tr>
                <tr>
                    <th><i class="require">*</i> 文章标题：</th>
                    <td>
                        <input type="text" class="lg" name="art_title">
                    </td>
                </tr>
                <tr>
                    <th>编辑：</th>
                    <td>
                        <input type="text" class="sm" name="art_editor" value="{{old('art_editor')}}">
                    </td>
                </tr>
                <tr>
                    <th>缩略图：</th>
                    <td>
                        <input type="text" size="50" name="art_thumb" value="{{old('art_thumb')}}">
                        <input type="text" id="file_upload_1"/>

                    </td>
                </tr>
                <tr>
                    <th></th>
                    <td>
                        <img src="{{old('art_thumb')}}" alt="" id="art_thumb_img" style="max-width: 350px; max-height:100px;">
                    </td>
                </tr>
                <tr>
                    <th>关键词：</th>
                    <td>
                        <input type="text" class="lg" name="art_tag" value="{{old('art_tag')}}">
                    </td>
                </tr>
                <tr>
                    <th>描述：</th>
                    <td>
                        <textarea name="art_description">{{old('art_description')}}</textarea>
                    </td>
                </tr>

                <tr>
                    <th>文章内容：</th>
                    <td>
                        <script id="editor" name="art_content" type="text/plain" style="width:860px;height:500px;">{!!old('art_content')!!}</script>
                    </td>
                </tr>

                <tr>
                    <th></th>
                    <td>
                        <input type="submit" value="提交">
                        <input type="button" class="back" onclick="history.go(-1)" value="返回">
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
@endsection

@section('my_js')
    {{--图片上传插件开始--}}
    <link rel="stylesheet" href="{{env('__COMMON__')}}uploadify/uploadify.css"/>
    <script type="text/javascript" src="{{env('__COMMON__')}}uploadify/jquery.uploadify.min.js"></script>
    <script>

        <?php $timestamp = time();?>
        $(function () {
            $('#file_upload_1').uploadify({
                'buttonText': '图片上传',
                'formData': {
                    'timestamp': '<?php echo $timestamp;?>',
                    '_token': "{{csrf_token()}}"
                },
                swf: '{{env('__COMMON__')}}uploadify/uploadify.swf',
                uploader: '{{url('admin/upload')}}',
                'onUploadSuccess': function (file, data, response) {
                    $('input[name=art_thumb]').val(data);
                    $('#art_thumb_img').attr('src',data);
//                                    alert(data);
                }
            });
        });

    </script>
    <style>
        .uploadify {
            display: inline-block;
        }

        .uploadify-button {
            border: none;
            border-radius: 5px;
            margin-top: 8px;
        }

        table.add_tab tr td span.uploadify-button-text {
            color: #FFF;
            margin: 0;
        }
    </style>
    {{--图片上传插件结束--}}
    {{--富文本编辑器开始--}}
    <script type="text/javascript" charset="utf-8" src="{{env('__COMMON__')}}ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="{{env('__COMMON__')}}ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="{{env('__COMMON__')}}ueditor/lang/zh-cn/zh-cn.js"></script>
    <script>
        var ue = UE.getEditor('editor');
    </script>
    <style>
        .edui-default{line-height: 28px;}
        div.edui-combox-body,div.edui-button-body,div.edui-splitbutton-body
        {overflow: hidden; height:20px;}
        div.edui-box{overflow: hidden; height:22px;}
    </style>
    {{--富文本编辑器结束--}}
@endsection